import java.io.*; class demo { public static void main(String args[])throws Exception { int arr[]={134654665,284976359,375696944,478499493,588388383, 698876566,764545453,855454545,978656544,107474733}; FileOutputStream fout=new FileOutputStream("c:/temp/num.txt"); DataOutputStream ds=new DataOutputStream(fout); for(int i=0;i<arr.length;i++) ds.writeInt(arr[i]); ds.close(); fout.close(); System.out.println("values stored..."); } }
values stored...
import java.io.*; class demo { public static void main(String args[])throws Exception { FileInputStream fin=new FileInputStream("c:/temp/num.txt"); DataInputStream ds=new DataInputStream(fin); for(int i=1;i<=10;i++) { int n=ds.readInt(); System.out.println(n); } ds.close(); fin.close(); } }
134654665 284976359 375696944 478499493 588388383 698876566 764545453 855454545 978656544 107474733
import java.io.*; class demo { public static void main(String args[])throws Exception { RandomAccessFile rd=new RandomAccessFile("c:/temp/num.txt","r"); rd.skipBytes(4); int a=rd.readInt(); rd.skipBytes(8); int b=rd.readInt(); rd.seek(32); int c=rd.readInt(); rd.close(); System.out.println("Values are "+a+" "+b+" "+c); } }
Values are 284976359 588388383 978656544